package com.fjec.user.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@FeignClient(name = "market-serv", fallback = MarketClientFallback.class)
public interface MarketClient {

    @RequestMapping(method = RequestMethod.GET, value = "/api/getSessionInfo")
    Map<String, Object> getSessionInfo(@RequestParam("userId") Long userId, @RequestParam("busiType") int busiType);

    /**
     * 根据userId获取用户名称及头像等信息
     *
     * @param userId
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/get/sessionInfo/by/userId")
    Map<String, Object> getSessionInfoByUserId(@RequestParam("userId") Long userId);

    /**
     * 保存个人信息
     *
     * @param userId
     * @param coopId
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/personal/save")
    boolean savePersonal(
            @RequestParam("userId") Long userId,
            @RequestParam(name = "coopId", required = false) Long coopId,
            @RequestParam(name = "nickName", required = false) String nickName,
            @RequestParam(name = "headPic", required = false) String headPic
    );

    /**
     * 修改个人信息，昵称和头像
     *
     * @param userId
     * @param nickName
     * @param headPic
     * @return
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/personal/update")
    boolean updatePersonal(
            @RequestParam("userId") Long userId,
            @RequestParam(value = "nickName", required = false) String nickName,
            @RequestParam(value = "headPic", required = false) String headPic
    );

}
